package com.example.androidxdemo.fragment

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.navigation.Navigation
import androidx.navigation.fragment.navArgs
import com.example.androidxdemo.R
import com.example.androidxdemo.databinding.FragmentExampleCBinding

/**
 * @author : ${USER}
 * @date   : ${DATE} ${TIME}
 * @desc   :
 */
class GlobleFragment : BaseFragment() {
    var binding: FragmentExampleCBinding? = null
    private val args: GlobleFragmentArgs by navArgs()

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        binding = FragmentExampleCBinding.inflate(inflater, container, false)
        if (arguments != null && !args.fromViewPager) {
            binding?.btJumpA?.setOnClickListener {
                Navigation.findNavController(it)
                    .navigate(R.id.action_exampleCFragment_to_globleStartAFragment)
            }
            binding?.btJumpB?.setOnClickListener {
                Navigation.findNavController(it)
                    .navigate(R.id.action_exampleCFragment_to_globleStartBFragment)
            }
        } else {
            binding?.btJumpA?.visibility = View.GONE
            binding?.btJumpB?.visibility = View.GONE
        }
        return binding?.root
    }

    override fun onDestroyView() {
        super.onDestroyView()
        binding = null
    }
}